package io.mya.modules.sys.controller; 

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.mya.common.annotation.SysLog;
import io.mya.common.utils.R;
import io.mya.common.validator.ValidatorUtils;
import io.mya.common.validator.group.AddGroup;
import io.mya.common.validator.group.UpdateGroup;
import io.mya.modules.sys.entity.TokenInfoEntity;
import io.mya.modules.sys.service.TokenInfoService;
 

/**
 * @author lxq
 * @email  1129507961@qq.com
 */
@RestController
@RequestMapping("/token/tokeninfo")
public class TokenInfoController extends AbstractController{
	@Autowired
	private TokenInfoService tokenInfoService;
	 
	/**
	 * 添加
	 * 
	 */
	@RequestMapping("/save")	 
	public R addToken(@RequestBody TokenInfoEntity TokenInfo){		 
		ValidatorUtils.validateEntity(TokenInfo, AddGroup.class);		 
		tokenInfoService.save(TokenInfo);		
		return R.ok();
	}
	/**
	 * 修改
	 */
	@SysLog("修改")
	@RequestMapping("/update")	
	public R update(@RequestBody TokenInfoEntity TokenInfo){
		ValidatorUtils.validateEntity(TokenInfo, UpdateGroup.class);
		tokenInfoService.update(TokenInfo);		
		return R.ok();
	}
	/**
	 * 获取信息
	 */
	@RequestMapping("/info/{id}")	
	public R info(@PathVariable("id") Long id){
		TokenInfoEntity tokenInfo = tokenInfoService.queryObject(id);	
		return R.ok().put("tokenInfo", tokenInfo);
	}
	/**
	 * 删除用户
	 */
	@SysLog("删除")
	@RequestMapping("/delete")	
	public R delete(@RequestBody Long id){			
		tokenInfoService.deleteBatch(id);		
		return R.ok();
	}
	/**
	 * 修改状态
	 */
	@SysLog("修改状态")
	@RequestMapping("/upstatus")
	public R upuserstatus(Long id,String status){
		tokenInfoService.upstatus(id,status);		
		return R.ok();
	}
}
